var o1:string
console.log(o1,typeof o1)

var o2={};
console.log(o2["prop"])

function method(prop){
    console.log(prop)
}
method(1)

var list1:number[]=[1,2,3];
var list2:Array<string>=['a','b','c']

var tuple1:[string,number]=["zhangsan",18]
console.log(`name is ${tuple1[0]},age is ${tuple1[1]}`)
tuple1[0]="lisi"
tuple1.push("TypeScript")
tuple1.push(1101)

enum Result{
    Success=10,
    Fail
}
var res:Result=Result.Success
console.log(res)

enum Direction{
    Up='Up',
    Down="Down",
    Left="Left",
    Right="Right"
}
var direction:Direction=Direction.Down
console.log(direction)

var some:any=1;
some="Hello"
console.log(some)
console.log((<string>some).length)
console.log((some as string).length)

function func1(x,y){
    return x+y;
}
var func2=function(x,y){
    return x+y;
}
console.log(func1(1,2))
console.log(func2(2,3))

function func5(success:boolean,msg?:string){
    if(!success){
        console.log(msg)
    }
}
func5(false,"Hello")
func5(false)
function func6(a:string,b:string,...other:string[]){
    console.log(a,b,other)
}
func6("Hello","World","TypeScript","JavaScript")
function funct7(param){
    if(typeof param==='string'){
        console.log("执行字符串逻辑")
    }
    if(typeof param==='number'){
        console.log("执行数字逻辑")
    }
    return param
}
funct7("Hello")
funct7(6)

function func8(a:string):string;
function func8(a:number):number;
function func8(param:string|number):string|number{
    if(typeof param==='string'){
        console.log("执行字符串逻辑")
    }
    if(typeof param==='number'){
        console.log("执行数字逻辑")
    }
    return param;
}
func8("Hello")
func8(6)
